package deployr.core;

import static java.text.MessageFormat.*;

public class JettyContexts {

	private final FileSystem fs;

	public JettyContexts(FileSystem fs) {
		this.fs = fs;
	}

	public void add(String appId) {
		fs.put(contextNameFor(appId), contextContentFor(appId));
	}

	private byte[] contextContentFor(String appId) {
		return new JettyContextXml(appId).getBytes();
	}

	private String contextNameFor(String appId) {
		return format("{0}.xml", appId);
	}

	public void remove(String appId) {
		fs.delete(contextNameFor(appId));
	}

}
